Fix tree view checkbox selection for backup dialog. #9649#9671
Fix tree view checkbox selection for backup dialog. #9649#9671RohitBhati8269 wants to merge 2 commits intopgadmin-org:masterfrom
Conversation
WalkthroughReplaces PgTreeView's selection callback to update the clicked node, its descendants, and ancestor indeterminate states, then collects all checked and indeterminate nodes and passes them (with isIndeterminate flags) to the existing selectionChange callback. Also adapts backup UI to destructure the new node wrapper. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@web/pgadmin/static/js/PgTreeView/index.jsx`:
- Line 91: Change the concise-arrow forEach callbacks to block-bodied arrows
that explicitly perform their side effects and return nothing; e.g., replace the
single-expression callback in the n.children?.forEach(child =>
updateDescendants(child, val)); call with a block-bodied callback that calls
updateDescendants(child, val) inside braces, do the same for the forEach inside
collectAllCheckedNodes (which currently has a bare return;) and the third
flagged forEach at line 146 so none of the forEach callbacks have implicit
returns; this will satisfy the lint rule and keep intent explicit.
- Around line 126-131: The code mutates the parent-owned node data by setting
n.data.isIndeterminate, causing stale flags; instead stop mutating n.data and
create a wrapper object for each selected node (e.g., push { node: n,
isIndeterminate: state === 'indeterminate' } into allCheckedNodes) so
isIndeterminate is derived from checkedState/newState rather than stored on
n.data; update the selectionChange call-site and the backup-dialog consumer to
read isIndeterminate from the wrapper object (or the wrapper's property) instead
of node.data.isIndeterminate so the flag is always correct and never mutates the
original data.
3969615 to
a3f1c05
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/pgadmin/static/js/PgTreeView/index.jsx (1)
233-238:⚠️ Potential issue | 🟡 MinorPropTypes are out of sync with actual props.
DefaultNodereceivesisCheckedandonToggleprops (lines 198, 201) but PropTypes liststreeandonNodeSelectionChangeinstead.🔧 Proposed fix
DefaultNode.propTypes = { node: PropTypes.object, style: PropTypes.any, - tree: PropTypes.object, hasCheckbox: PropTypes.bool, - onNodeSelectionChange: PropTypes.func + isChecked: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]), + onToggle: PropTypes.func };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@web/pgadmin/static/js/PgTreeView/index.jsx` around lines 233 - 238, The DefaultNode PropTypes are incorrect: replace the obsolete props `tree` and `onNodeSelectionChange` with the actual props used by the component (`isChecked` and `onToggle`). Update DefaultNode.propTypes so it declares node: PropTypes.object, style: PropTypes.any, hasCheckbox: PropTypes.bool, isChecked: PropTypes.bool, and onToggle: PropTypes.func (remove `tree` and `onNodeSelectionChange`) to match the usages in DefaultNode.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@web/pgadmin/static/js/PgTreeView/index.jsx`:
- Around line 233-238: The DefaultNode PropTypes are incorrect: replace the
obsolete props `tree` and `onNodeSelectionChange` with the actual props used by
the component (`isChecked` and `onToggle`). Update DefaultNode.propTypes so it
declares node: PropTypes.object, style: PropTypes.any, hasCheckbox:
PropTypes.bool, isChecked: PropTypes.bool, and onToggle: PropTypes.func (remove
`tree` and `onNodeSelectionChange`) to match the usages in DefaultNode.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
web/pgadmin/static/js/PgTreeView/index.jsxweb/pgadmin/tools/backup/static/js/backup.ui.js
entire tree, not just the clicked node's subtree
checked (state === true) and indeterminate states
between full schema selection and partial table selection
to collect a complete selection state
Summary by CodeRabbit